package com.example.mapper;

import com.example.entity.StudentAnswer;
import com.example.entity.Subject;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author： wzz
 * @date： 2021-11-02 21:07
 */

public interface SubjectMapper {



    @Update("update studentanswer set score =#{score} where menu_topic=#{menu_topic} and questionNo=#{questionNo} and studentNumber=#{studentNumber}")
    int updateScore(String menu_topic,String questionNo,String studentNumber,int score);

    @Select("select stem from subject where book_name=#{book_name} and menu_topic=#{menu_topic}" +
            "and question_number=#{questionNo}")
    String getStem(StudentAnswer studentAnswer);
    /**
     * 获取正确答案
     * @param studentAnswer
     * @return
     */
    String getAnswer(StudentAnswer studentAnswer);

    /**
     * 导入题目
     * @return
     */
    int importSubject(List<Subject> subjectList);




    @Select("select * from subject where book_name=#{book_name} and menu_topic=#{menu_topic}")
    List<Subject> hasContent(String book_name,String menu_topic);


    @Delete("delete from subject where book_name=#{book_name} and menu_topic=#{menu_topic} and question_number=#{question_number}")
    Integer SubjectDelete(Subject subject);

    @Update("update subject set stem=#{stem},option_one=#{option_one},option_two=#{option_two}," +
            "option_three=#{option_three},option_four=#{option_four},answer=#{answer}" +
            " where book_name=#{book_name} and menu_topic=#{menu_topic} and question_number=#{question_number} ")
    Integer SubjectUpdate(Subject subject);

}
